package com.yuanss.smartdemo.controller.customer;

import com.yuanss.smartdemo.model.Customer;
import com.yuanss.smartdemo.service.CustomerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description  客户创建
 * Servelt 与 Tomcat的关系：https://blog.csdn.net/xgb2018/article/details/114083042
 * @Date 2024/11/15 上午11:01
 * @Created by 菜到不敢run
 */
@WebServlet("/customer")
public class CustomerServlet extends HttpServlet {

    private CustomerService customerService;

    // 初始化
    @Override
    public void init() throws ServletException {
        customerService = new CustomerService();
    }

    // 客户列表
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Customer> customerList = customerService.getCustomerList("");
        req.setAttribute("customerList", customerList);
        req.getRequestDispatcher("/WEB-INF/jsp/customer.jsp").forward(req, resp);
    }
}
